"""
    文件操作工具包
"""


def print_file_info(file_name):
    """
        读取文件全部内容， 路径错误则返回错误信息
    :param file_name: 传入的路径
    :return:
    """
    f = None
    try:
        f = open(file_name, 'r', encoding="UTF-8")
        print(f.readlines())
    except Exception as e:
        print(e, '出错了')
    finally:
        if f:
            f.close()


def append_to_file(file_name, data):
    f = None
    try:
        f = open(file_name, 'a', encoding="UTF-8")
        f.write(data)
    except Exception as e:
        print(e)
    finally:
        f.close()


if __name__ == '__main__':
    print_file_info('/Users/yanfeixingsan/Documents/进阶之路/python/test/01-test.txt')
    append_to_file('/Users/yanfeixingsan/Documents/进阶之路/python/test/01-test.txt', '\n写入于2023-05-21早上8:23\n')